program def compuda
	syntax [if] [in], ///
		ta(str) Asset(str) rev(str) rec(str) ppe(str) Year(str) Industry(str) Generate(str)

	qui{
	gen __TA = `ta'
	gen __A = L.`asset'
	gen __dREC = D.`rec'
	gen __dREV = D.`rev'
	gen __PPE = `ppe'
	
	gen __TA_A=__TA/__A
	gen ___A=1/__A
	gen __REV_A=__dREV/__A
	gen __PPE_A=__PPE/__A
	gen __REC_A=__dREC/__A
	
	egen __group = group(`year' `industry')
	
	gen __b1=.
	gen __b2=.
	gen __b3=.
	gen __NDA=.
	gen `generate'=.
	}
	qui sum __group
	local max = r(max)
	forvalues i = 1/`max'{
		cap reg __TA_A ___A __REV_A __PPE_A if __group == `i', nocon
		cap replace __b1 = _b[ ___A ] if __group == `i'
		cap replace __b2 = _b[ __REV_A ] if __group == `i'
		cap replace __b3 = _b[ __PPE_A ] if __group == `i'
		cap replace __NDA=__b1*___A+__b2*(__REV_A - __REC_A )+__b3*__PPE_A  if __group == `i'
		cap replace `generate' = __TA_A-__NDA if __group == `i'
		dis "Computing `i' in `max' groups..."
	}
	drop __*
end
